Skip to content

refactor: remove dead code and consolidate duplicated helpers - #129

Merged
unvalley merged 2 commits into
mainfrom
refactor-codebase-sweep
Oct 29, 2026
Merged

unvalley merged 2 commits into
mainfrom
refactor-codebase-sweep

Conversation

@unvalley

Copy link
Copy Markdown
Owner

Behavior-preserving cleanup: remove dead code found by knip, and merge logic that was copy-pasted between the editor, the command menu and the storage modules.

  • Delete unused files: use-cursor-position.ts, use-toc.ts, table-of-contents.tsx, error-boundary.tsx, loading.tsx
  • Un-export file-local symbols; remove the unused codemirror package (keep @babel/core, pinned in fix: restore react compiler and stop history modal render loop #128)
  • Drop the history today/yesterday/older grouping, computed in useHistoryData but never rendered
  • Load history data synchronously instead of wrapping localStorage reads in promises with a 500ms timeout and a date-string cache
  • Share useMarkdownFormatter and formatEditorView (format, restore cursor and scroll) between the editor and the command menu
  • Share saveSnapshotWithToast between ⌘⇧S and the command menu
  • Move the cross-tab localStorage adapter to cross-tab-storage.ts; use it for both editorContentAtom and documentsAtom
  • Move getByDate into createStorage; drop task-storage pass-through methods and unused default providers
  • Add activeContentAtom for the char and word counts
  • Deduplicate task-line parsing in task-close.ts (parseTaskInfo), the heading check (isHeadingLine), font cycling (nextFontFamily), the history-tab openers and the command menu's close keys
  • Use formatDateKey for "Closed today"; only listen for outside clicks while the System menu is open

Validation: tsc --noEmit, pnpm lint, vitest run src (157 passed), vite build. playwright test passes 7; the same 3 fail on main (Picture-in-Picture close on leaving, and the two link-styling tests). In the dev server, in both single and multi mode: counts, ⌘S / ⌘⇧S, every command menu action, System menu font cycling, counts and outside click, closing a task by checkbox, history list/restore/delete/delete all, and cross-tab sync.

Found but not fixed here (reproduced on main): restoring a snapshot writes the raw string to ephe:editor-content instead of JSON, so the restored content is gone after a reload.

- Delete unused files, exports and the codemirror meta package
- Share markdown formatting and snapshot saving between the editor and command menu
- Move cross-tab storage, getByDate and the active-document lookup into shared helpers
- Deduplicate task-line parsing, heading detection and font cycling
- Load history data synchronously
@unvalley
unvalley merged commit 306e54f into main Oct 29, 2026
4 checks passed
@unvalley
unvalley deleted the refactor-codebase-sweep branch October 29, 2026 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant